from pathlib import Path
path = Path('day16/alice.txt')

try:
    contents = path.read_text(encoding='utf-8')
except FileNotFoundError:
    print(f"Sorry, the file {path} doesn't exist. ")
else:
    words = contents.split()        #split() 生成一个列表，包含童话中的所有单词
    num_words = len(words)
print(f"The file {path} has about {num_words}.")